// ==UserScript==
// @label                  Firefox-classic-menu.uc.js
// @description       Modified from FirefoxBtnMod.uc.js
// @labelspace       <a href="http://bbs.kafan.cn/thread-1794709-1-1.html" target="_blank">右键单击三道杠弹出经典菜单</a>
// @author              skofkyo
// @license               MIT License
// @compatibility    Firefox 29+
// @charset              UTF-8
// @version              2014.12.12
// @startup        
// @shutdown
// @config         
// @homepageURL    
// @ohomepageURL    
// @reviewURL    
// @downloadURL    
// @note                   
// @include              main
// @include              chrome://browser/content/browser.xul
// ==/UserScript==
 
(function() {
var FirefoxBtnpopup = document.createElement("menupopup");
FirefoxBtnpopup.setAttribute("id", "FirefoxBtnpopup");
var menubutton = document.getElementById("PanelUI-button")
menubutton.appendChild(FirefoxBtnpopup);
menubutton.addEventListener("contextmenu", function(event) {
      document.getElementById("FirefoxBtnpopup").openPopupAtScreen(event.screenX, event.screenY, true); 
      event.preventDefault();
}, false);
function menuadd() {
            var n, Item, FavIDs;
            FavIDs = [
                'file-menu',
                'edit-menu',
                'view-menu',
                'history-menu',
                'bookmarksMenu',
                'tools-menu',
                'helpMenu',
                'menu_preferences',
                '-',
                'menu_openDownloads',
                'menu_openAddons',
                'webDeveloperMenu',
                'javascriptConsole',
                '-',
                'aboutName',
                'restart',
                'menu_FileQuitItem',
            ];
            for (n = 0; n < FavIDs.length; n++) {
                var FavID = FavIDs[n];
                if (FavID == '-') {
                    Item = document.createElement("menuseparator");
                } else if (FavID == 'javascriptConsole') {
                    Item = document.createElement("menuitem");
                    Item.setAttribute("label", "错误控制台");
                    Item.setAttribute("image", "");
                    Item.setAttribute("oncommand", "toJavaScriptConsole();");
                } else if (FavID == 'restart') {
                    Item = document.createElement("menuitem");
                    Item.setAttribute("label", "重新启动浏览器");
                    Item.setAttribute("image", "");
                    Item.setAttribute("oncommand", "Services.appinfo.invalidateCachesOnRestart() || Application.restart();");
                } else {
                    Item = document.getElementById(FavID);
                }
                if (Item != null) FirefoxBtnpopup.appendChild(Item);
            }
        }
         
        setTimeout(function() {
            menuadd();
        }, 2000);
 
})();